<template>
  <div v-if="show">
    <template v-if="getConfirmMessage()">
      <el-popconfirm :title="getConfirmMessage()" @confirm="handleButtonClick" icon="el-icon-warning" icon-color="red">
        <el-button
            :type="viewButtonData.cls"
            plain slot="reference"
            size="mini"
            v-hasPermi="[viewButtonData.id]"
            :disabled="disabled"
            :loading="loading"
        ><rva-button-config :button="viewButtonData" @rva-button-click="handleButtonConfigClick"></rva-button-config></el-button>
      </el-popconfirm>
    </template>
    <template v-else>
      <el-button
          :type="viewButtonData.cls"
          plain
          size="mini"
          @click="handleButtonClick"
          v-hasPermi="[viewButtonData.id]"
          :disabled="disabled"
          :loading="loading"
      ><rva-button-config :button="viewButtonData" @rva-button-click="handleButtonConfigClick"></rva-button-config></el-button>
    </template>
    <template v-if="viewButtonData.action == 'dialog'">
      <el-dialog :title="viewButtonData.name" :visible.sync="open" v-if="open" :width="dialogWidth" append-to-body>
        <rva-form v-if="viewButtonData.type == 'form' && dialogFormParams" :viewId="viewButtonData.actionDialogViewId"
                  :requestParams="dialogFormParams" @rva-button-click="handleFormButtonClick"
                  @rva-form-width="setDialogWidth"
        ></rva-form>
        <template v-if="viewButtonData.type == 'tcrud'">
          <rva-tcrud v-if="dialogAppParams.trigger > 0" :appId="viewButtonData.actionDialogAppId"
                     :requestParams="dialogAppParams" @rva-button-click="handleFormButtonClick"></rva-tcrud>
        </template>
        <template v-if="viewButtonData.type == 'crud'">
          <rva-crud v-if="dialogAppParams.trigger > 0" :appId="viewButtonData.actionDialogAppId" :requestParams="dialogAppParams"></rva-crud>
        </template>
      </el-dialog>
    </template>
  </div>
</template>

<script>

import button from '@/api/rva/button'

export default {
  name: "RvaListViewTopButton",
  mixins: [button]
};
</script>
